﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace PDX
{
    /// <summary>
    /// Defines scope-related attached properties for PDX
    /// </summary>
    public static class Scope
    {

        /// <summary>
        /// Gets the notification scope.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns></returns>
        public static object GetNotificationScope(DependencyObject obj)
        {
            return (object)obj.GetValue(NotificationScopeProperty);
        }

        /// <summary>
        /// Sets the notification scope.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="value">The value.</param>
        public static void SetNotificationScope(DependencyObject obj, object value)
        {
            obj.SetValue(NotificationScopeProperty, value);
        }

        /// <summary>
        /// This property points to a key to be used to define the notification scope.
        /// PDX elements sharing a notification scope will be notified when one of them
        /// changes.
        /// </summary>
        public static readonly DependencyProperty NotificationScopeProperty =
            DependencyProperty.RegisterAttached("NotificationScope", typeof(object), typeof(Scope),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits,
                new PropertyChangedCallback(Raiser.Raise)));



        /// <summary>
        /// Gets the change tracking scope.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <returns></returns>
        public static object GetChangeTrackingScope(DependencyObject obj)
        {
            return (object)obj.GetValue(ChangeTrackingScopeProperty);
        }

        /// <summary>
        /// Sets the change tracking scope.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="value">The value.</param>
        public static void SetChangeTrackingScope(DependencyObject obj, object value)
        {
            obj.SetValue(ChangeTrackingScopeProperty, value);
        }

        /// <summary>
        /// Similar to the <see cref="NotificationScopeProperty"/>, setting this property
        /// defines which change tracking group elements belong to.
        /// It should be bound to an <see cref="ChangeTracking.ISnapshotHandler"/>.
        /// </summary>
        public static readonly DependencyProperty ChangeTrackingScopeProperty =
            DependencyProperty.RegisterAttached("ChangeTrackingScope", typeof(object), typeof(Scope),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.Inherits,
                new PropertyChangedCallback(Raiser.Raise)));

    }
}
